<?php
/**
 * Created by PhpStorm.
 * User: s.utkin
 * Date: 04.12.2014
 * Time: 18:56
 */

namespace Users\Register\Helper;

use Photos\File;
use Users\Profile;
use Users\TwitterConfig as Config;


trait Twitter {
	use \Pinenut\User\Auth\TwitterAuth;

	public function config() {
		$config = Config::get ();
		$config ['redirectUrl'] = 'http://' . $_SERVER ['HTTP_HOST'] . $this->url ( 'users.register.twitter' );
		$this->config = $config;

		return $config;
	}

	public function createAuth($data) {
		$auth = new \Pinenut\User\OAuth2\Twitter();

		$this->data = $data;
		$this->auth = $auth;

		if (isset($this->data->id_str)) {
			$auth->type = 'twitter';
			$auth->id = $this->data->id_str;
			return $auth;
		}
	}

	public function profile() {
		$profile = new Profile();
		$profile->nickname = $this->data->screen_name;

		return $profile;
	}


} 